package com.briup.day20;

public class Test_ThreadSafe {
    public static void main(String[] args) {
        TicketRunnable t=new TicketRunnable();
        Thread th1=new Thread(t,"窗口一");
        Thread th2=new Thread(t,"窗口二");
        Thread th3=new Thread(t,"窗口三");
        th1.start();
        th2.start();
        th3.start();
    }
}
class TicketRunnable implements Runnable {
    private  int num=50;
    @Override
    public void run() {
        while (true){
            if(num<=0){
                break;
            }
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            String name = Thread.currentThread().getName();
            System.out.println(name+"正在买票"+num);
            num--;
        }

    }
}